package com.medical.blood.controller;

import com.medical.blood.dto.OperationStatsDTO;
import com.medical.blood.dto.SampleAnalysisDTO;
import com.medical.blood.service.DataAnalysisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;

@RestController
@RequestMapping("/analysis")
public class DataAnalysisController {

    @Autowired
    private DataAnalysisService analysisService;

    /**
     * 获取运营数据统计报表
     * @param startTime 开始时间
     * @param endTime 结束时间
     */
    @GetMapping("/operation")
    public OperationStatsDTO getOperationStats(
            @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date startTime,
            @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime) {
        return analysisService.getOperationStats(startTime, endTime);
    }

    /**
     * 获取样本与结果分析报表
     */
    @GetMapping("/sample")
    public SampleAnalysisDTO getSampleAnalysis(
            @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date startTime,
            @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime) {
        return analysisService.getSampleAnalysis(startTime, endTime);
    }
}